<?php

class spCheckbox extends spDiv
{
	private $input; 

	public function __construct( $data )
	{
		parent::__construct();
	
		$readonly 	= isset( $data["readonly"] ) 	? $data["readonly"]	: false;
		$title 		= isset( $data["title"] ) 		? $data["title"]	: "";
		$name 		= isset( $data["name"] ) 		? $data["name"]		: "";
		$value 		= isset( $data["value"] ) 		? $data["value"]	: "";
		$class 		= isset( $data["class"] ) 		? $data["class"]	: "";
	
		$this->input = new spInput(array(
			"class"		=> $class,
			"type" 		=> "checkbox",
			"readonly" 	=> $readonly,
			"name"		=> $name,
			"value"		=> $value
		));
		parent::addChild( $this->input );
		
		parent::addChild( new spLabel(array(
			"content" => $title
		)));
		
		parent::addChild( new spBreak );
	}
	
	/*
		$checked : true | false
	*/
	
	public function setCheckbox( $checked )
	{
		if ( $checked==true )
			$this->input->addAttr( "checked", "checked" );
	}
}

?>